package cn.edu.sdu.sduhour.mapper;

import cn.edu.sdu.sduhour.entity.State;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface StateMapper {
    //查询所有状态记录
    @Select("select * from state")
    List<State> findAll();

    //查询某人状态记录
    @Select("select * from state where openid=#{openid}")
    List<State> findOne(State state);

    //添加一条状态记录
    @Update("INSERT INTO `sduhour`.`state` (`openid`, `center`, `hongjialou`, `xinglongshan`, `qianfoshan`, `baotuquan`, `ruanjianyuan`, `qingdao`, `weihai`) VALUES (#{openid}, 0, 0, 0, 0, 0, 0, 0, 0)")
    void addOne(State state);

    //更改一条状态记录
    @Update("UPDATE `sduhour`.`state` SET ${changeName}=1 WHERE openid=#{openid}")
    void setOne(State state);

    //删除一条状态记录
    @Delete("DELETE FROM `state` WHERE `id` = #{id}")
    void delOne(State state);
}